#ifndef XGE_XDATA_STRUCTURE_H_
#define XGE_XDATA_STRUCTURE_H_
#include "xge_common_config.h"
#include "xstl_allocator.h"

// stl header for data-structure

#include <list>
#include <vector>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <hash_map>
#include <set>

namespace xge{

  // list
  template < typename T > struct list {
    typedef std::list< T , xge_internal::STLAllocator< T > > List;
  };

  // vector
  template < typename T > struct vector {
    typedef std::vector< T , xge_internal::STLAllocator< T > > Vector;
  };

  // map
  template < typename K , typename T , typename LessCompare = std::less<K> > struct map {
    typedef std::map< K , T , LessCompare , xge_internal::STLAllocator< std::pair< const K , T > > > Map;
  };

  // multimap
  template < typename K , typename T , typename LessCompare = std::less<K> > struct multimap {
    typedef std::multimap< K , T , LessCompare , xge_internal::STLAllocator< std::pair< const K , T > > > Multimap;
  };

  // deque
  template < typename T > struct deque {
    typedef std::deque< T , xge_internal::STLAllocator< T > > Deque;
  };

  // hash_map
  template < typename K , typename T , typename HashCompare = std::hash_compare< K , std::less<K> > > struct hash_map {
    typedef stdext::hash_map< K , T , HashCompare , xge_internal::STLAllocator< std::pair< const K , T > > > 
      HashMap;

  };

  // set
  template < typename K , typename LessCompare = std::less<K> > struct set {
    typedef std::set< K ,  LessCompare , xge_internal::STLAllocator<K> > Set;
  };

  // multiset
  template < typename K ,typename LessCompare = std::less<K> >  struct multiset {
    typedef std::multiset< K , LessCompare , xge_internal::STLAllocator<K> > Multiset;
  };

  // stack
  template < typename T , typename Container = xge::vector<T>::Vector > struct stack {
    typedef std::stack< T , Container > Stack;
  };

  namespace {
    template <class T , class C > class op_queue:  public std::queue<T,C> {
      typedef std::queue<T,C> base;
    public:
      typedef C container_type;
      typedef typename base::value_type value_type;
      typedef typename base::size_type size_type;
      typedef typename base::reference reference;
      typedef typename base::const_reference const_reference;
    public:
      // I just add a interface to get the container from the priority queue
      // since we have no way to get container from priority queue
      // in queue also ( stl standard do not have )
      const container_type& container() const {
        return c;
      }
    };

    template <class T , class C ,class Pr> 
    class op_priority_queue : public std::priority_queue<T,C,Pr> {
      typedef std::queue<T,C> base;
    public:
      typedef C container_type;
      typedef typename base::value_type value_type;
      typedef typename base::size_type size_type;
      typedef typename base::reference reference;
      typedef typename base::const_reference const_reference;

    public:
      // I just add a interface to get the container from the priority queue
      // since we have no way to get container from priority queue
      // in queue also ( stl standard do not have )
      const container_type& container() const {
        return c;
      }

    };
  }
  //queue
  template < typename T , typename Container = vector<T>::Vector > struct queue {
    typedef op_queue<T,Container > Queue;
  };
  // priority_queue
  template < typename T , typename Container = vector<T>::Vector , typename LessCompare = std::less< Container::value_type > > struct priority_queue {
    typedef op_priority_queue< T , Container, LessCompare > PriorityQueue;
  };

}// namespace xge

#endif// XGE_XDATA_STRUCTURE_H_